package com.swanclouds.redfish.internal;

import com.swanclouds.api.types.ServiceType;
import com.swanclouds.core.transport.ClientConstants;
import com.swanclouds.model.common.redfish.CollectionResource;
import com.swanclouds.redfish.common.redfish.CollectionResourceModel;

/**
 * 系统资源基础服务
 *
 * @author:  张立强
 */
public class BaseSystemService extends BaseRedfishService {

    public BaseSystemService() {
        super(ServiceType.SYSTEMS);
    }

    private static ThreadLocal<String> systemsContainer = new ThreadLocal<>();

    /**
     * 获取系统资源ID
     * @return system_id
     */
    public String getSystemId() {
        if (systemsContainer.get() != null) {
            return systemsContainer.get();
        }
        CollectionResource resource = get(CollectionResourceModel.class, uri(ClientConstants.PATH_SYSTEMS)).execute();
        return getResourceId(resource, systemsContainer);
    }

}
